package com.threeox.permissions;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.util.Log;

/**
 * 
 * @ClassName: PermissionsRequest
 * 
 * @Description: TODO(权限请求的类)
 * 
 * @author 赵屈犇
 * 
 * @date 创建时间: 2017/8/25 13:48
 * 
 * @version 1.0
 * 
 */
public class PermissionsRequest {

    private int mRequestCode;
    private Activity mActivity;
    private String[] mPermissions;

    public PermissionsRequest(Activity activity, String[] permissions, int requestCode) {
        this.mActivity = activity;
        this.mRequestCode = requestCode;
        this.mPermissions = permissions;
    }

    /**
     * 请求权限
     */
    @TargetApi(Build.VERSION_CODES.M)
    public void requestPermissions() {
        try {
            ActivityCompat.requestPermissions(mActivity, mPermissions, mRequestCode);
        } catch (Exception e) {
            Log.e("PermissionsRequest", e.getMessage());
        }
    }
}
